package org.work;
import java.sql.*;
import org.model.Xsb;
public class DBConn {
	Connection conn;
	PreparedStatement pstmt;
	public DBConn(){
		try{
			Class.forName("com.mysql.jdbc.Driver");
		//	String url = "jdbc:mysql://localhost:3306/XSB? user=root&password=lina&useUnicode=true&characterEncoding=gbk";
			//Connection conn = DriverManager.getConnection(url);
			conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/XS","root","lina");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public boolean save(Xsb xs){
		try{
			pstmt=conn.prepareStatement("insert into XSB values(?,?,?,?,?,?)");		
			pstmt.setString(1,xs.getXh());
			pstmt.setString(2,xs.getXm());
			pstmt.setByte(3,xs.getXb());			
			pstmt.setDate(4,xs.getCssj());
			pstmt.setString(5,xs.getZy());
			pstmt.setString(6,xs.getBz());
			System.out.println(xs.getXh());
			System.out.println(xs.getXm());
			pstmt.executeUpdate();
			return true;
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}
}
